import os

from zhipuai import ZhipuAI


# api_key = os.getenv('ZHIPU_AI_KEY')
api_key = '5fcf2199235b4d73a7ea1ffd0a24c494.zbRNZdIh5lOFQVXt'
client = ZhipuAI(api_key=api_key)  # 请填写您自己的API Key
response = client.chat.completions.create(
  # model="glm-4-0520",  # 填写需要调用的模型编码
  model="GLM-4-Flash",  # 填写需要调用的模型编码
  messages=[
      {"role": "user", "content": "中国首都是哪里,需要介绍500字"},
  ],
  stream=False,
)

print(response.choices[0].message)

# for chunk in response:
#     print(chunk.choices[0].delta.content)
